			package com.lovemanai.dialer;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		//给按钮设置侦听
		//1.拿到按钮对象
		Button bt = (Button) findViewById(R.id.bt_call);
		//2.给按钮设置侦听
		bt.setOnClickListener(new MyListener());
	}
	
	class MyListener implements OnClickListener {
		
		//按钮被点击这个方法被调用
		@Override
		public void onClick(View v) {
			
			//获取电话号码
			EditText et = (EditText) findViewById(R.id.et_call);
			String phone = et.getText().toString();
			
			//告诉系统需要执行的动作：打电话
			//1.创建意图对象
			Intent intent = new Intent();
			//2.把动作封装到意图对象中
			intent.setAction(Intent.ACTION_CALL);
			//3.设置打给谁
			intent.setData(Uri.parse("tel:" + phone));
			//将动作告诉系统
			startActivity(intent);
			
		}
		
	}
}
